home *** CD-ROM | disk | FTP | other *** search
/ Gigarom 1 / Gigarom Macintosh Archives (Quantum Leap)(CDRM1080320)(1993).iso / FILES / DEV / A-B / AETracker.sea / AETracker Monitor.c next >
C/C++ Source or Header  |  1992-08-11  |  24KB  |  669 lines

  1. /* AETracker Monitor */
  2. /* 8/11/92  */
  3. /*  A sample program demonstrating the programatic interface to
  4.     version 3.0 and later of the AETracker INIT/Control Panel
  5. */
  6. /*  
  7. Application based on sample code provided by Apple Developer Technical Support. 
  8. AETracker interface routines provided by RavenWare Software
  9. */
  10.  
  11.  
  12. #include <Types.h>
  13. #include <memory.h>
  14. #include <Packages.h>
  15. #include <Errors.h>
  16. #include <quickdraw.h>
  17. #include <fonts.h>
  18. #include <dialogs.h>
  19. #include <windows.h>
  20. #include <menus.h>
  21. #include <events.h>
  22. #include <OSEvents.h>
  23. #include <Desk.h>
  24. #include <diskinit.h>
  25. #include <OSUtils.h>
  26. #include <resources.h>
  27. #include <toolutils.h>
  28. #include <AppleEvents.h>
  29. #include <EPPC.h>
  30. #include <GestaltEqu.h>
  31. #include <PPCToolbox.h> 
  32. #include <Processes.h>
  33. #include <Balloons.h>
  34.  
  35. #include "AETracker.h"
  36. /* prototypes */
  37. void InitalizeApp(void);
  38. void DoDiskEvents(long dinfo);                              /* hi word is error code, lo word is drive number */
  39. void DrawMain(WindowPtr drawIt);
  40. Boolean DoSelected(long val);
  41. void SpitStatus(AETrackExtParamPtr AETStatus);
  42. void InitAEStuff(void);
  43. void DoHighLevel(EventRecord *AERecord);
  44. void DoDaCall(MenuHandle themenu, long theit);
  45. pascal OSErr AEOpenHandler(AppleEvent *messagein, AppleEvent *reply, long refIn);
  46. pascal OSErr AEOpenDocHandler(AppleEvent *messagein, AppleEvent *reply, long refIn);
  47. pascal OSErr AEPrintHandler(AppleEvent *messagein, AppleEvent *reply, long refIn);
  48. pascal OSErr AEQuitHandler(AppleEvent *messagein, AppleEvent *reply, long refIn);
  49. void SampleHelpDialog(void);
  50. /* one external */
  51. extern void _DataInit();                                    /* this is the C initialization code */
  52.  
  53. #define kMBarID 128
  54. #define kAppleMenu 128
  55. #define kFileMenu 129
  56. #define kEditMenu 130
  57. #define kMonitorMenu 131
  58. #define kResumeMask     1   /* bit of message field for resume vs. suspend */
  59. #define kSampHelp 129
  60. #define kAboutBox 128
  61. #define kHelpString 128
  62. #define kNewItem 1
  63. #define kOpenItem 2
  64. #define kCloseItem 3
  65. #define kSaveItem 4
  66. #define kSaveAsItem 5
  67. #define kFileBlank1 6
  68. #define kPageSetupItem 7
  69. #define kPrintItem 8
  70. #define kFileBlank2 9
  71. #define kQuitItem 10
  72. #define kBadSystem 130
  73. #define kTitle 129
  74. #define kStatStrings 128
  75. enum  {
  76.     kAETActiveWord = 3, kOutFile = 5, kOnWord = 8, kOffWord, kNonEx, kEx, kRefCon, kRAddress
  77. };
  78. TEHandle theTE;
  79. struct AEinstalls {
  80.     AEEventClass theClass;
  81.     AEEventID theEvent;
  82.     EventHandlerProcPtr theProc;
  83. };
  84. typedef struct AEinstalls AEinstalls;
  85.  
  86. Boolean gAETInstalled;
  87. AETrackExtParam myParams;
  88. AETrackerStatusBlock myAETStatus;
  89. Handle gMymenu;                                             /* my menu bar handle */
  90. MenuHandle gAppleMenuHandle, gFileMenuHandle, gEditMenuHandle, gMonitorMenuHandle;
  91. Boolean gQuit, gInBackground;
  92. EventRecord gERecord;
  93. AEDesc gTheAddress;
  94. WindowPtr myWindow = nil;
  95. ProcessSerialNumber gOurSN;
  96. short gHelpItem;
  97. AETrackExternProcPtr externAE;
  98. pascal OSErr SampleIntercept(ParmBlkPtr paramBlock, long refCon);
  99. pascal OSErr SampleParseIntercept(Ptr AEParmPtr, long AESelector, long refCon);
  100.  
  101.  
  102. #pragma segment Main
  103. main()
  104. {
  105.     OSErr myErr;
  106.     WindowPtr twindow;
  107.     UnloadSeg((Ptr)_DataInit);                              /* throw out setup code */
  108.     InitalizeApp();
  109.     UnloadSeg((Ptr)InitalizeApp);                           /* get rid of my initialization code */
  110.     myErr = Gestalt('CKI3', (long *)&externAE);
  111.     if (myErr != noErr) {
  112.         short qq;
  113.         gAETInstalled = false;
  114.         StopAlert(131, nil);
  115.         for (qq = 1; qq < 4; qq++) {
  116.             DisableItem(GetMHandle(kMonitorMenu), qq);
  117.         }
  118.     } else {
  119.         gAETInstalled = true;
  120.     }
  121.     do {
  122.         WaitNextEvent(everyEvent, &gERecord, 30, nil);
  123.         switch (gERecord.what) {
  124.             
  125.             case nullEvent:
  126.                 /* no nul processing in this sample */
  127.                 if (!gInBackground && myWindow)
  128.                     TEIdle(theTE);
  129.                 break;
  130.             case updateEvt:
  131.                 DrawMain((WindowPtr)gERecord.message);      /* draw whatever window needs an update */
  132.                 break;
  133.             case mouseDown:
  134.                 /* first see where the hit was */
  135.                 switch (FindWindow(gERecord.where, &twindow)) {
  136.                     
  137.                     case inDesk:                            /* if they hit in desk, then the process manager */
  138.                         break;                              /* will switch us out, we don't need to do anything */
  139.                     case inMenuBar:
  140.                         DoSelected(MenuSelect(gERecord.where));
  141.                         break;
  142.                         
  143.                     case inSysWindow:
  144.                         /* pass to the system */
  145.                         SystemClick(&gERecord, twindow);
  146.                         break;
  147.                     case inContent:
  148.                         /* Handle content and control clicks here */
  149.                         GlobalToLocal(&gERecord.where);
  150.                         TEClick(gERecord.where, false, theTE);
  151.                         break;
  152.                     case inDrag:
  153.                         if (twindow == FrontWindow())
  154.                             DragWindow(twindow, gERecord.where, &qd.screenBits.bounds);
  155.                         break;
  156.                     case inGrow:
  157.                         /* Call GrowWindow here if you have a grow box */
  158.                         break;
  159.                     case inGoAway:
  160.                         /* Click in Close box */
  161.                         break;
  162.                         
  163.                 }
  164.             case mouseUp:
  165.                 /* don't care */
  166.                 break;
  167.                 /* same action for key or auto key */
  168.             case keyDown:
  169.             case autoKey:
  170.                 if (gERecord.modifiers & cmdKey)
  171.                     DoSelected(MenuKey(gERecord.message & charCodeMask));
  172.                 else
  173.                     TEKey(gERecord.message & charCodeMask, theTE);
  174.                 break;
  175.             case keyUp:
  176.                 /* don't care */
  177.                 break;
  178.             case diskEvt:
  179.                 /* I don't do anything special for disk events, this just passes them */
  180.                 /* to a function that checks for an error on the mount */
  181.                 DoDiskEvents(gERecord.message);
  182.                 break;
  183.             case activateEvt:
  184.                 if (gERecord.modifiers & activeFlag)
  185.                     DrawMain((WindowPtr)gERecord.message);
  186.                 break;
  187.             case networkEvt:
  188.                 /* don't care */
  189.                 break;
  190.             case driverEvt:
  191.                 /* don't care */
  192.                 break;
  193.             case app4Evt:
  194.                 switch ((gERecord.message >> 24) & 0x0FF) {     /* high byte of message */
  195.                     case suspendResumeMessage:              /* suspend/resume is also an activate/deactivate */
  196.                         gInBackground = (gERecord.message & kResumeMask) == 0;
  197.                         if (gInBackground)
  198.                             TEDeactivate(theTE);
  199.                         else
  200.                             TEActivate(theTE);
  201.                         break;
  202.                 }
  203.                 break;
  204.             default:
  205.                 break;
  206.                 /* This dispatches high level events (AppleEvents, for example) */
  207.                 /* to our dispatch routine.  This is NEW in the event loop for */
  208.                 /* System 7 */
  209.             case kHighLevelEvent:
  210.                 DoHighLevel(&gERecord);
  211.                 break;
  212.                 
  213.         }
  214.     }
  215.             while (gQuit != true);
  216.     
  217. }
  218.  
  219. /* DoDaCall opens the requested DA.  It's here as a seperate routine if you'd */
  220. /* like to perform some action or just know when a DA is opened in your */
  221. /* layer.  Can be handy to track memory problems when a DA is opened */
  222. /* with an Option-open */
  223. void DoDaCall(MenuHandle themenu, long theit)
  224. {
  225.     long qq;
  226.     char DAname[255];
  227.     GetItem(themenu, theit, &DAname);
  228.     qq = OpenDeskAcc(DAname);
  229. }
  230.  
  231. /* end DoDaCall */
  232.  
  233. /* DoDiskEvents just checks the error code from the disk mount, */
  234. /* and puts up the 'Format' dialog (through DIBadMount) if need be */
  235. /* You can do much more here if you care about what disks are */
  236. /* in the drive */
  237. void DoDiskEvents(long dinfo)                               /* hi word is error code, lo word is drive number */
  238. {
  239.     short hival, loval, tommy;
  240.     Point fredpoint =  {
  241.         40, 40
  242.     };
  243.     hival = HiWord(dinfo);
  244.     loval = LoWord(dinfo);
  245.     if (hival != noErr)                                     /* something happened */ {
  246.         tommy = DIBadMount(fredpoint, dinfo);
  247.     }
  248. }
  249.  
  250. /* draws my window.  Pretty simple */
  251. void DrawMain(WindowPtr drawIt)
  252. {
  253.     BeginUpdate(drawIt);
  254.     SetPort(drawIt);
  255.     EraseRect(&drawIt->portRect);
  256.     TEUpdate(&drawIt->portRect, theTE);
  257.     EndUpdate(drawIt);
  258. }
  259.  
  260. /* my menu action taker.  It returns a Boolean which I usually ignore, but it */
  261. /* mught be handy someday */
  262. Boolean DoSelected(long val)
  263. {
  264.     OSErr myErr = noErr;
  265.     short loval, hival;
  266.     Boolean returnVal = false;
  267.     loval = LoWord(val);
  268.     hival = HiWord(val);
  269.     
  270.     switch (hival) {                                        /* switch off the menu number selected */
  271.         case kAppleMenu:                                    /* Apple menu */
  272.             if (loval != 1) {                               /* if this was not About, it's a DA */
  273.                 DoDaCall(gAppleMenuHandle, loval);
  274.             } else {
  275.                 Alert(kAboutBox, nil);                      /* do about box */
  276.             }
  277.             returnVal = true;
  278.             break;
  279.         case kFileMenu:                                     /* File menu */
  280.             switch (loval) {
  281.                 case kQuitItem:
  282.                     gQuit = true;                           /* only  item */
  283.                     returnVal = true;
  284.                     break;
  285.                 default:
  286.                     break;
  287.             }
  288.             break;
  289.         case kEditMenu:
  290.             /* edit menu junk */
  291.             /* don't care */
  292.             break;
  293.         case kMonitorMenu:
  294.             /* add all your test stuff here */
  295.             /* only one item, kill stuff */
  296.             switch (loval) {
  297.                 StandardFileReply myReply;
  298.                 case 1:
  299.                     StandardPutFile("\p put it", "\pmytrack", &myReply);
  300.                     if (myReply.sfGood) {
  301.                         myParams.outFile = myReply.sfFile;
  302.                         myParams.flags = kAETUsePassedFileFSSpec;
  303.                     }
  304.                     myErr = externAE(&myParams, kAETToggle);                 /* Toggle */
  305.                     break;
  306.                 case 2:
  307.                     
  308.                     myParams.dataPtrs.statusData = &myAETStatus;
  309.                     myErr = externAE(&myParams, kAETStatus);                 /* Status */
  310.                     SpitStatus(&myParams);
  311.                     break;
  312.                 case 3:
  313.                     myParams.procs.outputPtr = SampleIntercept;
  314.                     /* pass my A5 so it will come back to me later */
  315.                     myParams.refCon = SetCurrentA5();
  316.                     myErr = externAE(&myParams, kAETInterceptOutput);                 /* Intercept output */
  317.                     break;
  318.                 case 4:
  319.                     myErr = externAE(&myParams, kAETReconnectOutput);                 /* reconnect output */
  320.                     break;
  321.                 case 5:
  322.                     
  323.                     myParams.procs.outputParsePtr = SampleParseIntercept;
  324.                     /* pass my A5 so it will come back to me later */
  325.                     myParams.refCon = SetCurrentA5();
  326.                     
  327.                     myErr = externAE(&myParams, kAETInterceptParse);                 /* intercept routines */
  328.                     break;
  329.                 case 6:
  330.                     myErr = externAE(&myParams, kAETReconnectParse);                 /* reconnect routines */
  331.                     break;
  332.                 case 7:
  333.                     myErr = externAE(nil,kAETEmergencyReset);
  334.                     break;
  335.                     
  336.             }
  337.             if(myErr)Debugger();
  338.             break;
  339.         case kHMHelpMenuID:                                 /* Defined in Balloons.h */
  340.             /* I only care about this item.  If anything else is returned here, I don't know what */
  341.             /* it is, so I leave it alone.  Remember, the Help Manager chapter says that */
  342.             /* Apple reserves the right to add and change things in the Help menu */
  343.             if (loval == gHelpItem)
  344.                 SampleHelpDialog();
  345.             break;
  346.             
  347.     }
  348.     HiliteMenu(0);
  349.     return(returnVal);
  350. }
  351.  
  352. /* InitAEStuff installs my appleevent handlers */
  353. void InitAEStuff(void)
  354. {
  355.     static AEinstalls HandlersToInstall[] =  { {
  356.             kCoreEventClass, kAEOpenApplication, AEOpenHandler
  357.         },  {
  358.             kCoreEventClass, kAEOpenDocuments, AEOpenDocHandler
  359.         },  {
  360.             kCoreEventClass, kAEQuitApplication, AEQuitHandler
  361.         },  {
  362.             kCoreEventClass, kAEPrintDocuments, AEPrintHandler
  363.         }, 
  364.         /* The above are the four required AppleEvents. */
  365.         
  366.     };
  367.     
  368.     OSErr aevtErr = noErr;
  369.     long aLong = 0;
  370.     Boolean gHasAppleEvents = false;
  371.     /* Check this machine for AppleEvents.  If they are not here (ie not 7.0)
  372.     * then we exit */
  373.     gHasAppleEvents = (Gestalt(gestaltAppleEventsAttr, &aLong) == noErr);
  374.     /* The following series of calls installs all our AppleEvent Handlers.
  375.     * These handlers are added to the application event handler list that 
  376.     * the AppleEvent manager maintains.  So, whenever an AppleEvent happens
  377.     * and we call AEProcessEvent, the AppleEvent manager will check our
  378.     * list of handlers and dispatch to it if there is one.
  379.     */
  380.     if (gHasAppleEvents) {
  381.         register qq;
  382.         for (qq = 0; qq < ((sizeof(HandlersToInstall) / sizeof(AEinstalls))); qq++) {
  383.             aevtErr = AEInstallEventHandler(HandlersToInstall[qq].theClass, HandlersToInstall[qq].theEvent,
  384.                                             HandlersToInstall[qq].theProc, 0, false);
  385.             if (aevtErr) {
  386.                 ExitToShell();                              /* just fail, baby */
  387.             }
  388.         }
  389.     } else {
  390.         ExitToShell();
  391.     }
  392. }
  393.  
  394. /* end InitAEStuff */
  395. /* I'm not doing error handling in this sample for clarities sake, you should. Hah, */
  396. /* easy for me to say, huh? */
  397. void DoHighLevel(EventRecord *AERecord)
  398. {
  399.     
  400.     AEProcessAppleEvent(AERecord);
  401.     
  402. }
  403.  
  404. /* end DoHighLevel */
  405.  
  406. /* This is the standard Open Application event.  */
  407. pascal OSErr AEOpenHandler(AppleEvent *messagein, AppleEvent *reply, long refIn)
  408. {
  409.     Rect theR;
  410. #pragma unused (messagein,reply,refIn)
  411.     /* we of course don't do anything here in this simple app */
  412.     /* except open our window */
  413.     myWindow = GetNewWindow(128, nil, (WindowPtr)-1);
  414.     SetPort(myWindow);
  415.     
  416.     theTE = TENew(&myWindow->portRect, &myWindow->portRect);
  417.     TEActivate(theTE);
  418.     TEAutoView(true, theTE);
  419.     return(noErr);
  420. }
  421.  
  422. /* end AEOpenHandler */
  423.  
  424. /* Open Doc, opens our documents.  Remember, this can happen at application start AND */
  425. /* anytime else.  If your app is up and running and the user goes to the desktop, hilites one */
  426. /* of your files, and double-clicks or selects Open from the finder File menu this event */
  427. /* handler will get called. Which means you don't do any initialization of globals here, or */
  428. /* anything else except open the doc.  */
  429. /* SO-- Do NOT assume that you are at app start time in this */
  430. /* routine, or bad things will surely happen to you. */
  431.  
  432. pascal OSErr AEOpenDocHandler(AppleEvent *messagein, AppleEvent *reply, long refIn)
  433. {
  434. #pragma unused (messagein,refIn,reply)
  435.     /* we of course don't do anything here */
  436.     return(errAEEventNotHandled);                           /* we have no docs, so no odoc events should come to us */
  437. }
  438.  
  439. pascal OSErr AEPrintHandler(AppleEvent *messagein, AppleEvent *reply, long refIn)
  440. {                                                           /* no printing handler in yet, so we'll ignore this */
  441.     /* the operation is functionally identical to the ODOC event, with the additon */
  442.     /* of calling your print routine.  */
  443. #pragma unused (messagein,refIn,reply)
  444.     /* we of course don't do anything here */
  445.     return(errAEEventNotHandled);                           /* we have no docs, so no pdoc events should come to us */
  446. }
  447.  
  448. /* Standard Quit event handler, to handle a Quit event from the Finder, for example.  */
  449. /* ••••• DO NOT CALL EXITTOSHELL HERE ••••• or you will never have a happy life.  */
  450. pascal OSErr AEQuitHandler(AppleEvent *messagein, AppleEvent *reply, long refIn)
  451. {
  452. #pragma unused (messagein,refIn,reply)
  453.     
  454.     /* prepQuit sets the Stop flag for us.  It does _NOT_ quit, you */
  455.     /* should NEVER quit from an AppleEvent handler.  Calling */
  456.     /* ExitToShell here would blow things up */
  457.     gQuit = true;
  458.     return(noErr);
  459. }
  460.  
  461. /* This is my sample help dialog.  Does not do anything, expand as you need */
  462. void SampleHelpDialog(void)
  463. {
  464.     DialogPtr tdial = GetNewDialog(kSampHelp, nil, (WindowPtr)-1);
  465.     short itemhit = 0;
  466.     while (itemhit != 1) {
  467.         ModalDialog((ModalFilterProcPtr)nil, &itemhit);
  468.     }
  469.     DisposDialog(tdial);
  470. }
  471.  
  472. /* This is a sample Text intercept routine */
  473. pascal OSErr SampleIntercept(ParmBlkPtr paramBlock, long refCon)
  474. {
  475.     OSErr myErr = noErr;
  476.     long oldA5;
  477.     Rect sampRect;
  478.     WindowPtr tempWP;
  479.     
  480.     GetPort(&tempWP);
  481.    /* •••• REMEMBER! A5 is set to the A5 of the application that made */
  482.     /* the AppleEvent call!.  You must set it to your own A5 if you */
  483.     /* want to access anything in your application */
  484.     oldA5 = SetCurrentA5(); /* save current A5 */
  485.     /* I passed my A5 as the refCon value when I installed my intercept routine */
  486.     SetA5(refCon);                
  487.     sampRect = myWindow->portRect;
  488.     SetPort(myWindow);
  489.     /* stuff the text in the TE record */
  490.     /* The parameter block that was passed to me is the same as the */
  491.     /* one used for PBWrite, so I'll use the buffer pointer and length */
  492.     TEInsert(paramBlock->ioParam.ioBuffer, paramBlock->ioParam.ioReqCount, theTE);
  493.     
  494.     SetA5(oldA5);    /* restore old A5 */
  495.     SetPort(tempWP);    /* restore port */
  496.     
  497.     return(myErr);    /* no errors */
  498. }
  499.  
  500. /* This is a sample parsing intercept routine */
  501. pascal OSErr SampleParseIntercept(Ptr AEParmPtr, long AESelector, long refCon)
  502. {
  503.     OSErr myErr = noErr;
  504.     OSType createdType;    
  505.     /* •••• REMEMBER! A5 is set to the A5 of the application that made */
  506.     /* the AppleEvent call!.  You must set it to your own A5 if you */
  507.     /* want to access anything in your application */
  508.     long oldA5 = SetCurrentA5(); /* save current A5 */
  509.     /* I passed my A5 as the refCon value when I installed my intercept routine */
  510.     SetA5(refCon);                    
  511.     
  512.     if(AESelector == 0x0B14){ /* is AECreateAppleEvent being called? */
  513.     DebugStr("\pAECreateAppleEvent called");
  514.     /* since the AEParmPtr points to the bottom of the parameter stack, */
  515.     /* I back up 18 bytes to find the class of AppleEvent being created */
  516.     createdType = *((OSType *) (AEParmPtr + 18));
  517.     
  518.     }
  519.      SetA5(oldA5);
  520.     return(myErr);
  521. }
  522.  
  523. /* quick and dirty routine to output status information to the current window */
  524. void SpitStatus(AETrackExtParamPtr AETStatus)
  525. {
  526.     Str255 theString;
  527.     char CR = 0xd;
  528.     char SP = 0x20;
  529.     
  530.     short qq = 1;
  531.     if (!gAETInstalled)
  532.         qq++;
  533.     GetIndString(theString, kStatStrings, qq);
  534.     TEInsert((Ptr)&theString[1], theString[0], theTE);
  535.     TEInsert((Ptr)&CR, 1, theTE);
  536.     
  537.     qq = kAETActiveWord;
  538.     if (!AETStatus->dataPtrs.statusData->AETActive)
  539.         qq++;
  540.     GetIndString(theString, kStatStrings, qq);
  541.     TEInsert((Ptr)&theString[1], theString[0], theTE);
  542.     TEInsert((Ptr)&CR, 1, theTE);
  543.     qq = kOutFile;
  544.     GetIndString(theString, kStatStrings, qq);
  545.     TEInsert((Ptr)&theString[1], theString[0], theTE);
  546.     TEInsert((Ptr)&SP, 1, theTE);
  547.     TEInsert((Ptr)&AETStatus->outFile.name[1], AETStatus->outFile.name[0], theTE);
  548.     TEInsert((Ptr)&CR, 1, theTE);
  549.     qq++;
  550.     
  551.     GetIndString(theString, kStatStrings, qq);
  552.     TEInsert((Ptr)&theString[1], theString[0], theTE);
  553.     TEInsert((Ptr)&CR, 1, theTE);
  554.     
  555.     qq = kOnWord;
  556.     if (!AETStatus->dataPtrs.statusData->fileInterceptActive)
  557.         qq++;
  558.     GetIndString(theString, kStatStrings, qq);
  559.     TEInsert((Ptr)&theString[1], theString[0], theTE);
  560.     TEInsert((Ptr)&CR, 1, theTE);
  561.     qq = kNonEx;
  562.     if (AETStatus->dataPtrs.statusData->fileExclusiveIntercept)
  563.         qq++;
  564.     GetIndString(theString, kStatStrings, qq);
  565.     TEInsert((Ptr)&theString[1], theString[0], theTE);
  566.     TEInsert((Ptr)&CR, 1, theTE);
  567.     qq = kRAddress;
  568.     GetIndString(theString, kStatStrings, qq);
  569.     TEInsert((Ptr)&theString[1], theString[0], theTE);
  570.     TEInsert((Ptr)&SP, 1, theTE);
  571.     
  572.     NumToString((long)AETStatus->dataPtrs.statusData->fileInterceptRoutine, theString);
  573.     TEInsert((Ptr)&theString[1], theString[0], theTE);
  574.     TEInsert((Ptr)&CR, 1, theTE);
  575.     qq = kRefCon;
  576.     GetIndString(theString, kStatStrings, qq);
  577.     TEInsert((Ptr)&theString[1], theString[0], theTE);
  578.     TEInsert((Ptr)&SP, 1, theTE);
  579.     
  580.     NumToString(AETStatus->dataPtrs.statusData->fileRefCon, theString);
  581.     TEInsert((Ptr)&theString[1], theString[0], theTE);
  582.     TEInsert((Ptr)&CR, 1, theTE);
  583.     
  584.     GetIndString(theString, kStatStrings, 7);
  585.     TEInsert((Ptr)&theString[1], theString[0], theTE);
  586.     TEInsert((Ptr)&CR, 1, theTE);
  587.     
  588.     qq = kOnWord;
  589.     if (!AETStatus->dataPtrs.statusData->parseInterceptActive)
  590.         qq++;
  591.     GetIndString(theString, kStatStrings, qq);
  592.     TEInsert((Ptr)&theString[1], theString[0], theTE);
  593.     TEInsert((Ptr)&CR, 1, theTE);
  594.     qq = kNonEx;
  595.     if (AETStatus->dataPtrs.statusData->parseExclusiveIntercept)
  596.         qq++;
  597.     GetIndString(theString, kStatStrings, qq);
  598.     TEInsert((Ptr)&theString[1], theString[0], theTE);
  599.     TEInsert((Ptr)&CR, 1, theTE);
  600.     qq = kRAddress;
  601.     GetIndString(theString, kStatStrings, qq);
  602.     TEInsert((Ptr)&theString[1], theString[0], theTE);
  603.     TEInsert((Ptr)&SP, 1, theTE);
  604.     
  605.     NumToString((long)AETStatus->dataPtrs.statusData->parseInterceptRoutine, theString);
  606.     TEInsert((Ptr)&theString[1], theString[0], theTE);
  607.     TEInsert((Ptr)&CR, 1, theTE);
  608.     qq = kRefCon;
  609.     GetIndString(theString, kStatStrings, qq);
  610.     TEInsert((Ptr)&theString[1], theString[0], theTE);
  611.     TEInsert((Ptr)&SP, 1, theTE);
  612.     NumToString(AETStatus->dataPtrs.statusData->parseRefCon, theString);
  613.     TEInsert((Ptr)&theString[1], theString[0], theTE);
  614.     TEInsert((Ptr)&CR, 1, theTE);
  615.     
  616.     
  617.     
  618.     
  619.     
  620. }
  621.  
  622.  
  623. #pragma segment Initialize
  624. void InitalizeApp(void)
  625. {
  626.     MenuHandle helpHandle;
  627.     StringHandle helpString;
  628.     short count;
  629.     long vers;
  630.     MaxApplZone();
  631.     InitGraf((Ptr)&qd.thePort);
  632.     InitFonts();
  633.     InitWindows();
  634.     InitMenus();
  635.     TEInit();
  636.     InitDialogs(nil);
  637.     InitCursor();
  638.     /* Check system version */
  639.     Gestalt(gestaltSystemVersion, &vers);
  640.     vers = (vers >> 8) & 0xf;                               /* shift result over and mask out major version number */
  641.     if (vers < 7) {
  642.         StopAlert(kBadSystem, nil);
  643.         ExitToShell();
  644.     }
  645.     InitAEStuff();
  646.     /* set up my menu junk */
  647.     gMymenu = GetNewMBar(kMBarID);
  648.     SetMenuBar(gMymenu);
  649.     gAppleMenuHandle = GetMHandle(kAppleMenu);
  650.     gFileMenuHandle = GetMHandle(kFileMenu);
  651.     gEditMenuHandle = GetMHandle(kEditMenu);
  652.     gMonitorMenuHandle = GetMHandle(kMonitorMenu);
  653.     AddResMenu(gAppleMenuHandle, 'DRVR');
  654.     /* now install my Help menu item in the Help Manager's menu */
  655.     HMGetHelpMenuHandle(&helpHandle);                       /* Get the Hlpe menu handle */
  656.     count = CountMItems(helpHandle);                        /* How many items are there? */
  657.     helpString = GetString(kHelpString);                    /* get my help string */
  658.     DetachResource(helpString);                             /* detach it */
  659.     HNoPurge(helpString);
  660.     MoveHHi((Handle)helpString);
  661.     HLock((Handle)helpString);
  662.     InsMenuItem(helpHandle, (Ptr)*helpString, count + 1);       /* insert my item in the Help menu */
  663.     gHelpItem = CountMItems(helpHandle);                    /* The number of the item */
  664.     
  665.     DrawMenuBar();
  666.     GetCurrentProcess(&gOurSN);                             /* Get our process serial number for later use, if needed */
  667.     
  668. }
  669.